package main.java.DMDE.infrastructure;

import java.util.ArrayList;
import java.util.List;
import main.java.DMDE.model.Diagram;

public class ProjectContext implements IProjectContext {

    private static String SubFolder = "Datos";
    private static String Path = "ejemplos";

    private List<Diagram> projectDiagrams;
    private List<Diagram> contextDiagrams;

    private String name;
    
    public ProjectContext(){
	this.projectDiagrams = new ArrayList<Diagram>();
	this.contextDiagrams = new ArrayList<Diagram>();
    }

    @Override
    public void clearContextDiagrams() {
	this.contextDiagrams.clear();
    }

    @Override
    public void clearProjectDiagrams() {
	this.projectDiagrams.clear();
    }

    @Override
    public void setName(String projectName) {
	this.name = projectName;
    }

    @Override
    public String getDataDirectory() {
	if (this.name != null) {
		return Path + "/" + this.name + "/" + SubFolder;
	}
	return null;
    }

    @Override
    public void addContextDiagram(Diagram diagram) {
	this.contextDiagrams.add(diagram);
    }

    @Override
    public void addProjectDiagram(Diagram diagram) {
	this.projectDiagrams.add(diagram);
    }

    @Override
    public Diagram getContextDiagram(String diagramName) {
	for (Diagram diagram : this.projectDiagrams)
		if (diagram.getName().equals(diagramName))
			return diagram;
	return null;
    }

}
